<template>
  <div class="main_app">
    <el-form :model="form" label-width="100px">
      <el-form-item label="服务器地址">
        <el-input v-model="form.host" />
      </el-form-item>
      <el-form-item label="评价器编号">
        <el-input v-model="form.clientNum" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script setup>
import { reactive } from "vue";
import { ElMessage } from 'element-plus'

const form = reactive({
  host: "",
  clientNum: "",
});

const onSubmit = () => {
  const bg = chrome.extension.getBackgroundPage();
  bg.saveSetting(form.host, form.clientNum);
  ElMessage({
    showClose: true,
    message: '保存成功',
    type: 'success',
  })
};
function created() {
  const bg = chrome.extension.getBackgroundPage();
  const { host, clientNum } = bg.getSetting();
  form.host = host;
  form.clientNum = clientNum
}
created();
</script>
<!-- 
<script>
export default {
  name: "popupView",
  data() {
    return {
      host: "",
      clientNum: "",
    };
  },
  created() {
    const bg = chrome.extension.getBackgroundPage();
    console.log(bg.getSetting());
    const { host, clientNum } = bg.getSetting();
    this.host = host;
    this.clientNum = clientNum;
  },
  methods: {
    onClick() {
      const bg = chrome.extension.getBackgroundPage();
      bg.saveSetting(this.host, this.clientNum);
      console.log(bg.getSetting());
    },
  },
};
</script> -->

<style>
.main_app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  width: 300px;
}
</style>
